package com.taxi.driver.module.main.mine.wallet.rules;

import android.content.Context;

import com.qianxx.adapter.SuperAdapter;
import com.qianxx.adapter.internal.SuperViewHolder;
import com.taxi.driver.R;
import com.taxi.driver.module.vo.RulesVO;
import com.taxi.driver.widget.ScalingTextView;

import java.util.ArrayList;

public class RulesAdapter extends SuperAdapter<RulesVO>{
    private int openIndex = -1;

    public RulesAdapter(Context context) {
        super(context, new ArrayList<RulesVO>(), R.layout.item_rules);
    }

    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, RulesVO item) {
        ScalingTextView stv=(ScalingTextView)holder.getView(R.id.stv);
        stv.setTitle(item.title);
        stv.setContent(item.content);
        if(openIndex == position){
            stv.open();
        }else{
            stv.close();
        }
        stv.setOnClickListener(new ScalingTextView.OnClickListener() {
            @Override
            public void onClick() {
                openIndex = position;
                notifyDataSetChanged();
            }
        });

    }
}
